package com.mad.gdrapps;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;


public class BeingASikhScr extends Activity implements Constants{

	
	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.sikhism);

	        try {
            
		        InputStream fis = this.getAssets().open("sikhism");
	            int size = fis.available();
	            byte[] buffer = new byte[size];
	            fis.read(buffer);
	            fis.close();
	            String fullContent = new String(buffer);       
	            Log.d("BANGLA","size of input tsream="+size);           
	            Log.d("BANGLA","full content="+fullContent);
	            
	            TextView tv1 = (TextView) findViewById(R.id.beingasikhTV);
	            tv1.setText(fullContent);
	            
	            setButtonListener((ImageButton)findViewById(R.id.being_gurusBtn), "gurus", "Ten Sikh Gurus");
	            setButtonListener((ImageButton)findViewById(R.id.being_moolBtn), "moolmantra", "The mool mantra");
	            setButtonListener((ImageButton)findViewById(R.id.being_evilsBtn), "evils", "Five evils");
	            setButtonListener((ImageButton)findViewById(R.id.being_pillarsBtn), "pillars", "Three pillars");
	            setButtonListener((ImageButton)findViewById(R.id.being_kakaarsBtn), "kakaars", "Five Kakaars");
	            
	            
	        } catch (IOException ioEx) {
            	
             	Log.e("BANGLA", ioEx.getMessage());
            	ioEx.printStackTrace();
            	
            }
            
	    }
 


		private void setButtonListener( ImageButton imgBtn, final String contentFileName, final String title){
			  
			imgBtn.setOnClickListener(new Button.OnClickListener() {
	          	
	          	public void onClick(View v){
	          		
	      			Intent intent = new Intent(getApplicationContext(), DisplayTextOnlyScr.class);
		        		Bundle b = new Bundle(1);
		        		b.putString(KEY_CONTENT_FILE_NAME, contentFileName);
		        		b.putString(KEY_CONTENT_TITLE, title);
		        		
		        		intent.putExtra(KEY_CONTENT_BUNDLE,b);
		        		startActivity(intent);
		        		
	          	}
	          });
		}
	 
}
